package scuts.core;
import utest.Assert;

using scuts.core.Lazy;

class LazyTest 
{

  public function new() 
  {
    
    
  }
  
  public function testLazy_expression_c_ShouldOnlyBeEvaluatedOnce () {
    var a = ["a", "b"];
    
    var calls = 0;
    var c = ({ calls++; 2+2;}).lazy();
    
    Assert.equals(0, calls);
    
    var c1 = c();
    var c2 = c();
    
    Assert.equals(4, c1);
    Assert.equals(4, c2);
    Assert.equals(1, calls);
  }
  
}